package com.pashanhoo.Thread.condition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

/**
 * @author 胡庆安
 * @version V1.0
 * @Package com.pashanhoo.Thread.condition
 * @date 2020/11/24 10:15
 * @Copyright © 2010-2020 爬山虎科技（扬州）股份有限公司
 */
public class ConditionDemoSignal implements
        Runnable {
    private Lock lock;
    private Condition condition;

    public ConditionDemoSignal(Lock lock,
                               Condition condition) {
        this.lock = lock;
        this.condition = condition;
    }

    @Override
    public void run() {
        System.out.println("begin - ConditionDemoSignal");
        try {
            lock.lock();
            condition.signal();
            System.out.println("end - ConditionDemoSignal");
        } finally {
            lock.unlock();
        }
    }

}
